package com.skydonkey.dao;

import com.skydonkey.pojo.po.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {
    @Insert("INSERT INTO categories (name) VALUES (#{name})")
    @Options(useGeneratedKeys = true, keyProperty = "categoryId")
    int insert(Category category);

    @Delete("DELETE FROM categories WHERE category_id = #{categoryId}")
    int delete(int categoryId);

    @Select("SELECT * FROM categories WHERE category_id = #{categoryId}")
    Category selectById(int categoryId);

    @Select("SELECT * FROM categories")
    List<Category> selectAll();
}
